import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import { useTheme } from './composables/useTheme'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { createPinia } from 'pinia'
import './style.css'

// 添加Fontawesome样式（为社交图标）
const fontawesomeCSS = document.createElement('link')
fontawesomeCSS.href = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css'
fontawesomeCSS.rel = 'stylesheet'
document.head.appendChild(fontawesomeCSS)

const app = createApp(App)
const { initTheme } = useTheme()

// 注册所有Element Plus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 使用Element Plus, Pinia和Router
app.use(router)
app.use(ElementPlus)
app.use(createPinia())

// 初始化主题
initTheme()

app.mount('#app')
